<?php


defined('BASEPATH') OR exit('No direct script access allowed');

class Request extends CI_Controller {
  public function index(){
  $code = $_GET["code"];
 //配置appid
  $appid = "wxe0d8a5c00d4c3da8";
  //配置appscret
  $secret = "26362b8d7f870db78989a6d0245bf5f9";
  //api接口
  $api = "https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$secret}&js_code={$code}&grant_type=authorization_code";
  //获取GET请求
  $get = file_get_contents($api);
  $get_return = (array)json_decode($get);
//$openid=$get_return['openid'];
  echo json_encode($get_return);

  }
}
